package org.nahtanoj.driveutils;

import java.io.IOException;

import com.google.api.client.googleapis.media.MediaHttpUploader;
import com.google.api.client.googleapis.media.MediaHttpUploaderProgressListener;

public class CustomProgressListener implements
MediaHttpUploaderProgressListener {
	private boolean output = false;

	@Override
	public void progressChanged(MediaHttpUploader uploader) throws IOException {
		switch(uploader.getUploadState()){
		case INITIATION_STARTED:
			break;
		case INITIATION_COMPLETE:
			break;
		case MEDIA_IN_PROGRESS:
			this.output = true;
			System.out.print(String.format("%.2f ", (100.0 * uploader.getProgress())));
			break;
		case MEDIA_COMPLETE:
			if (this.output == true) {
				System.out.println();
			}
			break;
		default:
			break;
		}

	}
}
